package com.xinchuang.controller.targetSystem;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xinchuang.comment.R;
import com.xinchuang.common.Result;
import com.xinchuang.service.targetSystem.indexUtil.IndexPullService;
import com.xinchuang.service.targetSystem.target.SystemIndexService;
import com.xinchuang.utils.CheckUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;

/**
 * SystemIndexController
 *
 * @author zkwczx
 * @date 2022-09-23
 */
@RestController
@RequestMapping("/systemIndex")
@Api(value = "指标体系", tags = "指标体系")
public class SystemIndexController {

    @Resource
    private SystemIndexService systemIndexService;

    @Resource
    private IndexPullService indexPullService;

    /**
     * 获取体系指标树接口  函数名称getIndexList  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/getIndexList")
    @ApiOperation("获取体系指标树")
    public R getIndexList(@RequestBody JSONObject jsonObject) {
        // 调用业务层代码
        String r = systemIndexService.getIndexList(jsonObject);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 新增平级指标接口  函数名称addIndex  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/addIndex")
    @ApiOperation("新增平级指标")
    public R addIndex(@RequestBody JSONObject jsonObject) {
        String r = systemIndexService.addIndex(jsonObject);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 新增下级指标接口  函数名称addSubIndex  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/addSubIndex")
    @ApiOperation("新增下级指标")
    public R addSubIndex(@RequestBody JSONObject jsonObject) {
        String r = systemIndexService.addSubIndex(jsonObject);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 新增底层指标接口  函数名称addLastIndex  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/addLastIndex")
    @ApiOperation("新增底层指标")
    public R addLastIndex(@RequestBody JSONObject jsonObject) {
        // 调用业务层代码
        return systemIndexService.addLastIndex(jsonObject);
    }

    /**
     * 编辑指标信息接口  函数名称updateIndex  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/updateIndex")
    @ApiOperation("编辑指标信息")
    public R updateIndex(@RequestBody JSONObject jsonObject) {
        // 调用业务层代码
        return systemIndexService.updateIndex(jsonObject);
    }

    /**
     * 删除指标接口  函数名称deleteIndex  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/deleteIndex")
    @ApiOperation("删除指标")
    public R deleteIndex(@RequestBody JSONObject jsonObject) {
        // 调用业务层代码
        String r = systemIndexService.deleteIndex(jsonObject);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 查询指标详细信息接口  函数名称queryIndex  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/queryIndex")
    @ApiOperation("查询指标详细信息")
    public String queryIndex(@RequestBody JSONObject jsonObject) {
        // 调用业务层代码
        return systemIndexService.queryIndex(jsonObject);
    }

    /**
     * 获取指标下级指标列表接口  函数名称getSubIndexList  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/getSubIndexList")
    @ApiOperation("获取指标下级指标列表")
    public R getSubIndexList(@RequestBody JSONObject jsonObject) {
        // 调用业务层代码
        String r = systemIndexService.getSubIndexList(jsonObject);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 编辑权重接口  函数名称setCustom  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/setCustom")
    @ApiOperation("编辑权重")
    public R setCustom(@RequestBody JSONObject jsonObject) {
        // 调用业务层代码
        String r = systemIndexService.setCustom(jsonObject);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 保存权重接口  函数名称saveType  功能描述:
     *
     * @param jsonObject 中文名:通用实体类
     * @return 返回参数{}
     */
    @PostMapping("/saveType")
    @ApiOperation("保存权重")
    public R saveType(@RequestBody JSONObject jsonObject) {
        // 调用业务层代码
        String r = systemIndexService.saveType(jsonObject);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 查询底层指标下拉
     *
     * @return
     */
    @PostMapping("/getIndexBankList")
    @ApiOperation("查询底层指标下拉")
    public R getIndexBankList() {
        return systemIndexService.selectIndexPull();
    }

    /**
     * 查询底层指标下拉
     *
     * @return
     */
    @PostMapping("/getTargetIndexBankList")
    @ApiOperation("查询目标指标底层指标下拉")
    public R getTargetIndexBankList(@RequestBody JSONObject jsonObject) {
        return systemIndexService.selectIndexPullByTarget(
                jsonObject.getString("targetId"),
                jsonObject.getString("typeId"),
                jsonObject.getString("type")
        );
    }

    /**
     * 查询底层指标下拉
     *
     * @return
     */
    @PostMapping("/getSubTypeKeyData")
    @ApiOperation("查询子目标类型数据")
    public R getSubTypeKeyData(@RequestBody JSONObject jsonObject) {
        String typeId = jsonObject.getString("typeId");
        if (StringUtils.isNotBlank(typeId)) {
            return indexPullService.selectSubTypeKeyValue(
                    typeId,
                    "Double"
            );
        }
        JSONArray array = jsonObject.getJSONArray("typeIds");
        if (CollectionUtil.isNotEmpty(array)) {
            return indexPullService.selectSubTypeShowType(array.getString(array.size() - 1));
        }
        return R.data(ListUtil.empty());
    }

    @PostMapping(value = "/copyIndexId")
    @ApiOperation("选择复制的指标ID")
    private Result copyIndexId(@RequestBody JSONObject json) {
        String typeId = json.getString("typeId");
        return systemIndexService.copyTypeId(typeId);
    }

    @PostMapping(value = "/copyIndexList")
    @ApiOperation("粘贴指标列表")
    private Result copyIndexList(@RequestBody JSONObject json) {
        String typeId = json.getString("typeId");
        return systemIndexService.copyIndexList(typeId);
    }

    @PostMapping(value = "/recoverIndex")
    @ApiOperation("恢复指标")
    private Result recoverIndex(@RequestBody JSONObject json) {
        String typeId = json.getString("typeId");
        return systemIndexService.recoverIndex(typeId);
    }


    public static String jsonLoop(Object object, String result, String methodName, Set<String> set) {
        Object v = null;
        if (object instanceof JSONArray || object instanceof ArrayList) {
            JSONArray jsonArray = new JSONArray();
            if (object instanceof ArrayList) {
                jsonArray = JSONArray.parseArray(JSON.toJSONString(object));
            } else {
                jsonArray = (JSONArray) object;
            }
            for (int i = 0; i < jsonArray.size(); i++) {
                result = jsonLoop(jsonArray.get(i), result, methodName, set);
                if (StringUtils.isNotEmpty(result)) {
                    return result;
                }
            }
        }
        if (object instanceof JSONObject) {
            JSONObject jsonObject = (JSONObject) object;
            for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
                Object o = entry.getValue();
                if (o instanceof JSONArray || o instanceof ArrayList) {
                    result += selectCheckMathod(entry.getKey(), entry.getValue(), methodName, set);
                    result = jsonLoop(o, result, methodName, set);
                    if (StringUtils.isNotEmpty(result)) {
                        return result;
                    }
                } else if (o instanceof JSONObject) {
                    result = jsonLoop(o, result, methodName, set);
                    if (StringUtils.isNotEmpty(result)) {
                        return result;
                    }
                } else {
//                   FIXME: 未知类型
                }
                if (entry.getValue() != null) {
                    v = entry.getValue();
                }
                result += selectCheckMathod(entry.getKey(), v, methodName, set);
            }
        }
        return result;
    }

    private static String selectCheckMathod(String key, Object value, String methodName, Set<String> set) {
        String result = "";
        if ("getIndexListSC".equals(methodName)) {
            result = getIndexListSC(key, value, set);
        }
        if ("getIndexListAC".equals(methodName)) {
            result = getIndexListAC(key, value, set);
        }
        if ("addIndexSC".equals(methodName)) {
            result = addIndexSC(key, value, set);
        }
        if ("addIndexAC".equals(methodName)) {
            result = addIndexAC(key, value, set);
        }
        if ("addSubIndexSC".equals(methodName)) {
            result = addSubIndexSC(key, value, set);
        }
        if ("addSubIndexAC".equals(methodName)) {
            result = addSubIndexAC(key, value, set);
        }
        if ("addLastIndexSC".equals(methodName)) {
            result = addLastIndexSC(key, value, set);
        }
        if ("addLastIndexAC".equals(methodName)) {
            result = addLastIndexAC(key, value, set);
        }
        if ("updateIndexSC".equals(methodName)) {
            result = updateIndexSC(key, value, set);
        }
        if ("updateIndexAC".equals(methodName)) {
            result = updateIndexAC(key, value, set);
        }
        if ("deleteIndexSC".equals(methodName)) {
            result = deleteIndexSC(key, value, set);
        }
        if ("deleteIndexAC".equals(methodName)) {
            result = deleteIndexAC(key, value, set);
        }
        if ("queryIndexSC".equals(methodName)) {
            result = queryIndexSC(key, value, set);
        }
        if ("queryIndexAC".equals(methodName)) {
            result = queryIndexAC(key, value, set);
        }
        if ("getSubIndexListSC".equals(methodName)) {
            result = getSubIndexListSC(key, value, set);
        }
        if ("getSubIndexListAC".equals(methodName)) {
            result = getSubIndexListAC(key, value, set);
        }
        if ("setCustomSC".equals(methodName)) {
            result = setCustomSC(key, value, set);
        }
        if ("setCustomAC".equals(methodName)) {
            result = setCustomAC(key, value, set);
        }
        if ("saveTypeSC".equals(methodName)) {
            result = saveTypeSC(key, value, set);
        }
        if ("saveTypeAC".equals(methodName)) {
            result = saveTypeAC(key, value, set);
        }
        if ("setAHPSC".equals(methodName)) {
            result = setAHPSC(key, value, set);
        }
        if ("setAHPAC".equals(methodName)) {
            result = setAHPAC(key, value, set);
        }
        if ("computeAHPSC".equals(methodName)) {
            result = computeAHPSC(key, value, set);
        }
        if ("computeAHPAC".equals(methodName)) {
            result = computeAHPAC(key, value, set);
        }
        return result;
    }


    private static String getIndexListSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("sysId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "体系标识", isNull, 0, 100);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String getIndexListAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if ("indicatorId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if ("indicatorName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标名称", isNull, 0, 200);
        }
        if ("indicatorValue".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标值", isNull, 0, 200);
        }
        if ("weight".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标权重", isNull, 0, 200);
        }
        if ("children".equals(key)) {
            result += CheckUtil.checkJSONArray(JSONArray.parseArray(JSON.toJSONString(value)), "children", isNull);
        }
        if ("indicatorId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if ("indicatorName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标名称", isNull, 0, 200);
        }
        if ("indicatorValue".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标值", isNull, 0, 200);
        }
        if ("weight".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标权重", isNull, 0, 200);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String addIndexSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("indicatorName".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标名称", isNull, 0, 200);
        }
        if ("remark".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "备注", isNull, 0, 9999);
        }
        if ("indicatorId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if ("parentId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "父级标识", isNull, 0, 100);
        }
        if ("sysId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "体系id", isNull, 0, 255);
        }
        if ("nodeType".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "类型", isNull, 0, 200);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String addIndexAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String addSubIndexSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("indicatorName".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标名称", isNull, 0, 200);
        }
        if ("remark".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "备注", isNull, 0, 9999);
        }
        if ("indicatorId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if ("parentId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "父级标识", isNull, 0, 100);
        }
        if ("sysId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "体系id", isNull, 0, 100);
        }
        if ("nodeType".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "类型", isNull, 0, 200);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String addSubIndexAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String addLastIndexSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("indicatorName".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标名称", isNull, 0, 200);
        }
        if ("remark".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "备注", isNull, 0, 9999);
        }
        if ("indicatorId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if ("parentId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "父级标识", isNull, 0, 100);
        }
        if ("sysId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "体系id", isNull, 0, 255);
        }
        if ("nodeType".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "类型", isNull, 0, 200);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String addLastIndexAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String updateIndexSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("indicatorId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if ("indicatorName".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标名称", isNull, 0, 200);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String updateIndexAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String deleteIndexSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("ids".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 9999);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String deleteIndexAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String queryIndexSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("indicatorId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String queryIndexAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if ("indicatorId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if ("indicatorName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标名称", isNull, 0, 255);
        }
        if ("remark".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "备注", isNull, 0, 255);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String getSubIndexListSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("indicatorId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if ("type".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "类型", isNull, 0, 200);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String getSubIndexListAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if ("data".equals(key)) {
            result += CheckUtil.checkJSONArray(JSONArray.parseArray(JSON.toJSONString(value)), "承载数据", isNull);
        }
        if ("indicatorId".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 255);
        }
        if ("indicatorName".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标名称", isNull, 0, 200);
        }
        if ("weight".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标权重", isNull, 0, 200);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String setCustomSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("sysId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "体系标识", isNull, 0, 100);
        }
        if ("indicatorId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if ("weight".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标权重", isNull, 0, 200);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String setCustomAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String saveTypeSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
//        if ("id".equals(key)) {
//            isNull = true;
//            // 判断参数类型: String  num boolean datetime
//            result += CheckUtil.checkString(value == null ? "" : value.toString(), "父级指标标识", isNull, 0, 30);
//        }
//        if ("dataList".equals(key)) {
//            result += CheckUtil.checkJSONArray(JSONArray.parseArray(JSON.toJSONString(value)), "权重列表", isNull);
//        }
        if ("indicatorId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
//        if ("weight".equals(key)) {
//            isNull = true;
//            // 判断参数类型: String  num boolean datetime
//            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "指标权重", isNull, "0", "200");
//        }
        if ("weightType".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "指标类型", isNull, "0", "200");
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String saveTypeAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String setAHPSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("sysId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "体系标识", isNull, 0, 100);
        }
        if ("indicatorAId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "标识A", isNull, 0, 100);
        }
        if ("indicatorBId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "标识B", isNull, 0, 100);
        }
        if ("weight".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标比重", isNull, 0, 200);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String setAHPAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String computeAHPSC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("indicatorId".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标标识", isNull, 0, 100);
        }
        if ("weightType".equals(key)) {
            isNull = true;
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "指标类型", isNull, 0, 100);
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String computeAHPAC(String key, Object value, Set<String> set) {
        String result = "";
        Boolean isNull = false;
        if ("code".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkBigDecimal(value == null ? "" : value.toString(), "状态码", isNull, "0", "100000");
        }
        if ("msg".equals(key)) {
            // 判断参数类型: String  num boolean datetime
            result += CheckUtil.checkString(value == null ? "" : value.toString(), "返回消息", isNull, 0, 255);
        }
        if ("success".equals(key)) {
            // 判断参数类型: String  num boolean datetime
        }
        if (isNull) {
            set.add(key);
        }
        return result;
    }

    private static String getIndexListACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("sysId");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String getIndexListACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String addIndexACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("indicatorId");
        list.add("indicatorName");
        list.add("sysId");
        list.add("nodeType");
        list.add("parentId");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String addIndexACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String addSubIndexACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("indicatorId");
        list.add("indicatorName");
        list.add("sysId");
        list.add("nodeType");
        list.add("parentId");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String addSubIndexACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String addLastIndexACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("indicatorId");
        list.add("indicatorName");
        list.add("sysId");
        list.add("nodeType");
        list.add("parentId");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String addLastIndexACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String updateIndexACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("indicatorId");
        list.add("indicatorName");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String updateIndexACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String deleteIndexACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("ids");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String deleteIndexACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String queryIndexACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("indicatorId");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String queryIndexACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String getSubIndexListACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("indicatorId");
        list.add("type");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String getSubIndexListACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String setCustomACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("indicatorId");
        list.add("sysId");
        list.add("weight");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String setCustomACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String saveTypeACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("indicatorId");
//        list.add("weight");
        list.add("weightType");
//        list.add("id");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String saveTypeACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String setAHPACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("sysId");
        list.add("indicatorAId");
        list.add("indicatorBId");
        list.add("weight");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String setAHPACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    private static String computeAHPACS(Set<String> set) {
        List<String> list = new ArrayList<>();
        list.add("indicatorId");
        list.add("weightType");
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "入参");
    }

    private static String computeAHPACB(Set<String> set) {
        List<String> list = new ArrayList<>();
        if (set.size() == list.size()) {
            return "";
        }
        return getCollectionDifferentValue(list, set, "出参");
    }

    /**
     * 获取集合中的不同值
     *
     * @param list
     * @param set
     * @return
     */
    private static String getCollectionDifferentValue(List<String> list, Set<String> set, String flag) {
        String result = "";
        for (String str : list) {
            if (!set.contains(str)) {
                result += str + ",";
            }
        }
        if (StringUtils.isNotEmpty(result)) {
            result = StringUtils.strip(result, ",");
            result = "---" + flag + ":" + result + "为必填参数";
        }
        return result;
    }
}
